package com.matt.controller.web;

import com.matt.commons.dto.sso.StaffDTO;
import com.matt.commons.exception.BusinessException;
import com.matt.commons.model.StatusResponse;
import com.matt.commons.utils.RemoteCallUtil;
import com.matt.domain.Children;
import com.matt.foundation.dto.AreaSettingDTO;
import com.matt.foundation.model.ErrorCode;
import com.matt.foundation.model.MemVerificationCache;
import com.matt.service.ChildrenService;
import com.matt.service.remoteCall.DTO.AreaListDTO;
import com.matt.service.remoteCall.SsoCallService;
import io.swagger.annotations.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.matt.foundation.constant.RequestConstant.TICKET;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/8/1
 * *******************************
 */
@RestController
@RequestMapping("/web/clientele")
@Api(tags = "客户模块 ")
public class WebClienteleController {
    @Autowired
    private SsoCallService ssoCallService;

    @Autowired
    private MemVerificationCache memVerificationCache;

    @Value("${server.crm.url}")
    private String crmServerURL;

    @Autowired
    private  ChildrenService childrenService;

    @RequestMapping(value = "/find", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取客户信息")
    public StatusResponse getClientele(@RequestHeader(TICKET) String ticket,String childrenId){
        Children children = childrenService.getById(childrenId);
        Map p = new HashMap();
        p.put("clientelesId", children.getCrmClienteleId());
        HashMap result = RemoteCallUtil.call(crmServerURL + "/api/other_system/detail", p, ticket, HashMap.class, "创建客户失败");
        return StatusResponse.success(result);
    }

}
